#pragma once

#include <cstdint>
#include <string>
#include <memory>

namespace cyb
{

class Resource
{
public:
	Resource( const std::string& name ) : m_name( name ) {}
	virtual ~Resource() = default;

	virtual bool Load() { return true; }
	virtual void UnLoad() {}
	virtual const size_t AllocatedSize() const { return 0; }
	const std::string& ResourceName() const { return m_name; }

private:
	std::string m_name;
};

class FileResource : public Resource
{
public:
	FileResource( const std::string& name );
	virtual ~FileResource() = default;

	virtual bool Load();
	virtual void UnLoad();
	virtual const size_t AllocatedSize() const;

	const std::string& Filename() const;
	const char* Buffer() const;
	char* WriteableBuffer( size_t* bufferSize = nullptr );

private:
	std::unique_ptr<char[]> m_buffer;
	size_t m_bufferSize;
	bool m_isLoaded;
};

}	// namespace cyb